package com.demo.thread.demo_thread_create_way;

/**
 * @author peter
 * @date 2022/3/12 11:16
 */
public class Demo2_1 implements Runnable{
    @Override
    public void run() {
        printThreadInfo();
    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new Demo2_1(), "方式1");
        Thread thread2 = new Thread(()->{
            printThreadInfo();
        }, "方式2");
        thread1.start();
        thread2.start();
    }

    private static void printThreadInfo() {
        System.out.println("当前线程ID" + Thread.currentThread().getId());
        System.out.println("当前线程名称" + Thread.currentThread().getName());
        System.out.println("当前线程状态" + Thread.currentThread().getState());
        System.out.println("当前线程优先级" + Thread.currentThread().getPriority());
    }
}
